(function( _ , $ ){
	_.Html.messager = "<div class='jdmer_mger_item'>"+
	"	<div class='mger_backgroud'>"+
	"		<div class='mger_left'></div>"+
	"		<div class='mger_center'></div>"+
	"		<div class='mger_right'></div>"+
	"	</div>"+
	"	<div class='mger_container'>"+
	"		<div class='mger_icon'></div>"+
	"		<div class='mger_content'></div>"+
	"		<div class='mger_button'></div>"+
	"	</div>"+
	"</div>";
	
	var Messager = {
		mgerObj : null,
		width : 100,
		show : function(_config){
			var config = {
				content : "",
				type : "alert",
				time : 5000,
				always : false
			};
			$.extend(config,_config);
			var _this = this;
			if(_this.mgerObj == null){	//如果对象为空，那么创建这个对象
				_this.mgerObj = $("<div class='jdmer_mger'></div>");
				_this.mgerObj.appendTo($("body"));
			}
			var contentObj = $(_.Html.messager);
			
			contentObj.appendTo(_this.mgerObj);
			contentObj.hide();
			contentObj.slideDown();
			contentObj.addClass("jdmer_mger_"+config.type);
			
			var bg = contentObj.children(".mger_backgroud");
			var bgLeft = bg.children(".mger_left");
			var bgCenter = bg.children(".mger_center");
			var bgRight = bg.children(".mger_right");
			var ctn = contentObj.children(".mger_container");
			var icon = ctn.children(".mger_icon");
			var content = ctn.children(".mger_content");
			var button = ctn.children(".mger_button");
			
			content.html(config.content);
			var cWidth = content.get(0).scrollWidth;
			content.width(cWidth);
			contentObj.width(cWidth + icon.width() + button.width()  + 8);
			bg.width(contentObj.width());
			bgCenter.width(bg.width() - bgLeft.width() - bgRight.width());
			
			contentObj.css("left",(_this.width - contentObj.width())/2);
			
			if(!config.always){
				var timeId = setTimeout(function(){
					contentObj.slideUp(function(){
						contentObj.remove();
					});
				},config.time);
			}
			button.click(function(){
				clearTimeout(timeId);
				contentObj.slideUp(function(){
					contentObj.remove();
				});
				button.unbind("click");
			});
		},
		error : function(_config){
			var config = {
				type : "error",
				always : true
			};
			if(typeof _config == "object"){
				$.extend(config,_config);
			}else if(typeof _config == "string"){
				config.content = _config;
			}
			this.show(config);
		},
		warn : function(_config){
			var config = {
				type : "warn"
			};
			if(typeof _config == "object"){
				$.extend(config,_config);
			}else if(typeof _config == "string"){
				config.content = _config;
			}
			this.show(config);
		},
		alert : function(_config){
			var config = {
				type : "alert"
			};
			if(typeof _config == "object"){
				$.extend(config,_config);
			}else if(typeof _config == "string"){
				config.content = _config;
			}
			this.show(config);
		},
		success : function(_config){
			var config = {
				type : "success"
			};
			if(typeof _config == "object"){
				$.extend(config,_config);
			}else if(typeof _config == "string"){
				config.content = _config;
			}
			this.show(config);
		}
	};
	_.Mger = _.Messager = Messager;
	
})(jDreamer,jQuery);